<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link rel="stylesheet" href="/js/chosen/chosen.css" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link type="text/css" href="/css/start/jquery-ui-1.8.21.custom.css" rel="Stylesheet" />	
<link type="text/css" href="/css/1pxtable.css" rel="Stylesheet" />	
<script type="text/javascript" src="/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="/js/jquery-ui-1.8.21.custom.min.js"></script>
<script>
$(function(){
	$("#box_barcode").keydown(function(e){
	    if(e.keyCode == 13){
	    	e.preventDefault();
	    	$('#box_qty').focus();
	    	$('#box_qty').select();
	    	return false;
	    }
	  });

	$("#box_qty").keydown(function(e){
	    if(e.keyCode == 13){
	        var barcode = $("#box_barcode").attr('value');
			var qty = $("#box_qty").attr('value');
	        
			var i = $("#count").attr('value');
			$("#table2").append('<tr valign = "top" id= "' + i + '" value = "3"><td align="center"><input type = "text" name = "barcode[]" id = "barcode_"' + parseInt(i) + '" value = "' + barcode + '"/></td><td align="center"><input type = "text" name = "qty[]" id = "qty_' + parseInt(i) + '" value = "'+ qty + '" /></td><td><a href="javascript:void(0);" id="remCF_' + i + '" class= "remCF" onclick="cancel(this)">Remove</a></td></tr>');
			$("#count").attr('value',(parseInt(i)+1));

			$('#box_barcode').val(""); 
			$(this).val("1");
			e.preventDefault();
	    	$('#box_barcode').focus();
	    	$('#box_barcode').select();
	    	return false;
	    }

	    
	  });

	
	  
});

function cancel(source){
	var currentId = $(source).attr('id');
	var id = currentId.split("_");
	$('#'+id[1]).remove();
}

function check(source){
	var v = $(source).attr('value');
	var orderNo = $('#order_no').attr('value');
	var boxNo = $('#box_no').attr('value');
	if(v.length > 1 && boxNo.length > 1 && orderNo.length > 1){
		$('#save').prop('disabled', false);
	}else{
		$('#save').prop('disabled', true);
	}
}

function transfer(order){
	window.location.href = 'http://115.64.171.97:1080/order/order-wizard-inchina-summary/orderNo/' + order;
}
</script>
</head>

<body>
<h1>
装箱清单
<br />

</h1>
<form action = "" method = "post" enctype="multipart/form-data">
<table width="500" border="1" cellspacing="0" cellpadding="10">
  
  <tr>
  	<th>扫描条形码</th>
  </tr>

  <tr>
    <td align="center">条码：<input type="text" name="box_barcode" id="box_barcode" /> x 
<input type="text" name="box_qty" id = "box_qty" value = "1" size = "5px"/>个</td>
  </tr>

</table>
<br/>
<br/>
<table width="500" border="1" cellspacing="0" cellpadding="10" id = "table2">
  <tr>
  	<th scope="col" colspan = "3">装箱清单</th>
  </tr>
  <tr>
  	<th scope="col">订单号码</th>
  	<th scope="col">箱号</th>
  	<th scope="col">&nbsp;</th>
  </tr>
  <tr>
   	<td align="center"><input type = "text" name = "orderNo" id = "order_no" value = "<?php if($this->orderNo){ echo $this->orderNo;}?>"/></td>
    <td align="center"><input type = "text" name = "boxNo"  id = "box_no"/></td>
    <td align="center">&nbsp;</td>
  </tr>
  <tr>
  	<th scope="col">条形码</th>
  	<th scope="col">数量</th>
  	<th scope="col">&nbsp;</th>
  </tr>
</table>
<input type = "hidden" id = "count" value = "1"></input>
Password <input type = "text" name = "password" id = "password" onchange = "check(this)"></input><input type = "submit" name = "save" id = "save" value = "保存" ></input>
</form>

<?php if($this->noBarcodeList){?>
	<h4><span style = "color:red;"></span>未订货产品，请检查条形码并重新扫描</h4>
	<table width="400" border="1" cellspacing="0" cellpadding="10">
		<tr>
			<th>条形码</th>
			<th>数量</th>
		</tr>
		<?php foreach ($this->noBarcodeList as $k => $v){
				foreach ($v as $k2 => $v2){?>
		<tr>
			<td><?php echo $v2['barcode']?></td>
			<td><?php echo $v2['qty']?></td>
		</tr>
		<?php 		}
				}?>
	</table>
<?php }?>
<br/>
<input type = "submit" onclick = "transfer('<?php echo $this->orderNo;?>')" value = "装箱完毕查看汇总"/>
</body>

<script src="/js/jquery-1.7.2.min.js" type="text/javascript"></script>
  <script src="/js/chosen/chosen.jquery.js" type="text/javascript"></script>
  <script type="text/javascript"> 
    var config = {
      '.chzn-select': {allow_single_deselect:true},
    }
    for (var selector in config) {
      $(selector).chosen(config[selector]);
    };
  </script>
</html>
